package pers.cl.dubbo.mvc;

import io.netty.handler.codec.http.FullHttpRequest;
import io.netty.handler.codec.http.FullHttpResponse;
import org.springframework.lang.Nullable;

import java.util.List;

/**
 * @author chenlei
 * @date 2020/1/14
 * @description
 **/
public class HandlerExecutionChain {

    private final Object handler;

    @Nullable
    private HandlerInterceptor[] interceptors;

    @Nullable
    private List<HandlerInterceptor> interceptorList;

    public HandlerExecutionChain(Object handler) {
        this.handler = handler;
    }


    /**
    *@author chenlei
    *@date 2020/1/14 15:08
    *@param
    *@return
    *@exception
    *@description  controller方法执行之前的逻辑
    **/
    boolean applyPreHandle(FullHttpRequest request, FullHttpResponse response) throws Exception {
        return true;
    }

    /**
    *@author chenlei
    *@date 2020/1/14 15:08
    *@param
    *@return
    *@exception
    *@description  controller方法执行之后的逻辑
    **/
    void applyPostHandle(FullHttpRequest request, FullHttpResponse response)
            throws Exception {
    }

    /**
     * Trigger afterCompletion callbacks on the mapped HandlerInterceptors.
     * Will just invoke afterCompletion for all interceptors whose preHandle invocation
     * has successfully completed and returned true.
     */
    void triggerAfterCompletion(FullHttpRequest request, FullHttpResponse response, @Nullable Exception ex)
            throws Exception {
    }

    /**
     * Apply afterConcurrentHandlerStarted callback on mapped AsyncHandlerInterceptors.
     */
    void applyAfterConcurrentHandlingStarted(FullHttpRequest request, FullHttpResponse response) {
    }
}
